﻿
var url = new Url();
var page = new Page();
//var serializer = new JSONSerializer();
var phone, idCard, cryptographic;
$(document).ready(function () {
    //判断浏览器是否支持localStorage缓存
    if (window.localStorage) {
        phone = localStorage.getItem("Phone");
        idCard = localStorage.getItem("IdCard");
        cryptographic = localStorage.getItem("Cryptographic");
    }
    else {
        phone = url.GetQueryString("Phone");
        idCard = url.GetQueryString("IdCard");
        cryptographic = url.GetQueryString("Cryptographic");
    }
    //发送AJAX请求判断用户是否可访问
    $.ajax({
        url: "../Handler/FinaInvestHandler.ashx",
        type: "post",
        dataType: "json",
        data: { type: 0, Phone: phone, IdCard: idCard, Cryptographic: cryptographic },
        async: true,
        complete: function () { },
        success: function (result) {
            if (!result.Status) {
                alert(result.Message);
                location.href = "InvestLogin.aspx";
            }
        }
    });
    //绑定我的投资、我的投资模式等信息
    $.ajax({
        url: "../Handler/FinaInvestHandler.ashx",
        type: "post",
        dataType: "json",
        data: { type: 2, Phone: phone, IdCard: idCard, Cryptographic: cryptographic },
        async: true,
        complete: function () { },
        success: function (result) {
            if (!result.Status) {
                alert(result.Message);
                location.href = "InvestLogin.aspx";
            }
            else {
                $("span.finaManager").text(result.Data.FinaManager);
                $("span.addUpInverst").text(result.Data.AddUpInverst);
                $("span.currentInverst").text(result.Data.CurrentInverst);
                $.each(result.Data.InverstMoneyList, function (index, item) {
                    $("#InverstMoneyTmpl").tmpl(item).appendTo("#inverstMoneyList");
                });
            }
        }
    });
    //设置分页信息
    page.Url = "../Handler/FinaInvestHandler.ashx";
    page.type = 1;
    page.Data.Phone = phone;
    page.Data.IdCard = idCard;
    page.Data.Cryptographic = cryptographic;
    page.CallBack = function (data) {
        $("#dataList").empty();

        $.each(data, function (index, item) {
            $("#IncomeTmpl").tmpl(item).appendTo("#dataList");
        });
      
    };
    page.GetPageData();

});
